<!--
* description: 车型配置弹出框（含输入框）
* author: zxuan
* createdDate: 2019-10-09
-->
<template>
  <section class="carTypeConfig" v-show="curIsShow" :key="fullComponentKey">
    <el-col :span="span">
      <lableName
      :style="span==12?'width:14%':''"
      :validrule="validrule"
        :curLabelName="curLabelName"
        :isShowLabel="isShowLabel"
        :isRequire="isRequire"
      ></lableName>
      <el-input
        :style="setInputWidth(span)"
        :placeholder="placeholder"
        v-model="modelText"
        :disabled="disabled"
        size="small"
        suffix-icon="el-icon-menu"
        @clear="clearCode"
        clearable
        @blur="sendCode"
        @focus="getFocusCode"
      ></el-input>
      <validateFormate :curLabelName="curLabelName"></validateFormate>
    </el-col>
    <car-type-config
      :popupsVisible="curPopupsVisible"
      :codeField="codeField"
      :textField="textField"
      :comType="comType"
      :valueObject="curValueObject"
      :popupsKey="popupsKey"
      :code="modelCode"
      :text="modelText"
      :key="curPopupsKey"
      :isMul="isMul"
      :returnCodeField="returnCodeField"
      :returnTextField="returnTextField"
      @changeCode="getComponentCode1"
      ref="dialogComponent"
    ></car-type-config>
  </section>
</template>
<script>
import { searchInputMixins } from "@/components/mixins/searchInputMixins";
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
import { crmApis } from "@/api/apiList/crm";
import { orgApis } from "@/api/apiList/org";
// import lableName from "@/components/lableName";
import CarTypeConfig from "@/components/crm/crmEjectWindows/crmCartypeNew/carTypeConfig";
// import validateFormate from "@/components/validateFormate";
export default {
  // 组件混入对象
  mixins: [searchInputMixins, valueObjectMixins],
  components: {
    CarTypeConfig,
    lableName: () => import("@/components/lableName"), //标题溢出样式组件
    validateFormate: () => import("@/components/validateFormate"), //校验提示样式组件
  },
  data() {
    return {
      placeholder: this.$t('sys.tips.esTip0'),
      curLabelName: this.labelName === "" ? this.$t('org.label.carConfig') : this.labelName
    };
  },
  methods: {
    // 重写显示时执行事件
    onShow() {
      var that = this;
      var parent = that.$utils.getHasFormFieldParentComponent(that);
      if (
        parent.formField &&
        parent.formField.inteSeriesId &&
        parent.formField.inteSeriesId !== ""
      ) {
        //赋值
        this.curValueObject.carSeriesId = parent.formField.inteSeriesId;
        this.curPopupsKey = this.codeField + this.$utils.generateId();
      }
    },
    //传递网格列数据
    getComponentCode1(code,text,codeField,comType,popupsKey,textField,otherField,selectData) {
      this.getComponentCode(code,text,codeField,comType,popupsKey,textField,otherField,selectData);
      var parent = this.$utils.getHasFormFieldParentComponent(this);
      let results = selectData[0];
      for (let key in parent.formField) {
        if (results.hasOwnProperty(key)) {
          parent.formField[key] = results[key];
        }
      }
      this.$emit("emitCode", selectData);
    },
    setInputWidth(span) {
      switch (span) {
        case 6:
          return "";
        case 12:
          return "width:85%;line-height: 38px;";
      }
    }
  }
};
</script>
